home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _29F4522A6C874FE6B72EF4958FB22D4D < prev    next >
Text File  |  2004-12-04  |  2KB  |  70 lines

  1. //dp logo swirl swirl
  2.  
  3. //Luke Lenhart
  4. //(C)2004-2005 Digipen Institute of Technology
  5.  
  6. //combined world,view,projection transform
  7. float4x4 matViewProj;
  8.  
  9. //animation position modifier (vary from 5 to 0)
  10. float mod;
  11.  
  12. //rotation around the z axis
  13. float hRot;
  14.  
  15. //direction of the light
  16. float3 lgtDirection;
  17.  
  18. //shader input
  19. struct VS_INPUT
  20. {
  21.     float4 Pos : POSITION;
  22.     float4 Normal : NORMAL;
  23.     float2 Tex0 : TEXCOORD0;
  24. };
  25.  
  26. //shader output
  27. struct VS_OUTPUT
  28. {
  29.     float4 Pos : POSITION;
  30.     float2 Tex0 : TEXCOORD0;
  31.     float4 Color : COLOR;
  32. };
  33.  
  34. //shader code
  35. VS_OUTPUT VShader(VS_INPUT In)
  36. {
  37.     VS_OUTPUT Out;
  38.     
  39.     //copy tex coord
  40.     Out.Tex0=In.Tex0;
  41.     
  42.     //animation vertex position swirl
  43.     float dist=distance(In.Pos.xz,float2(0,0)); //dist from center
  44.     float theta=dist*0.25f*mod + 2.0f*mod; //make a rotation
  45.     float2x2 matRot={cos(theta),sin(theta),-sin(theta),cos(theta)};
  46.     float4 pos=In.Pos;
  47.     pos.xz=mul(matRot,In.Pos.xz);
  48.     
  49.     //scale
  50.     pos.xz*=mod+1.0f;
  51.     
  52.     //rotate around z axis (pos and normal)
  53.     matRot=float2x2(cos(hRot),sin(hRot),-sin(hRot),cos(hRot));
  54.     pos.xy=mul(matRot,pos.xy);
  55.     
  56.     //calc transformed position
  57.     Out.Pos=mul(matViewProj,pos);
  58.     
  59.     //simple color calc
  60.     Out.Color.xyz=abs(dot(lgtDirection.xyz,In.Normal.xyz)*0.7f + float3(0.2f,0.2f,0.2f));
  61.     
  62.     //calc alpha
  63.     float alpha=0.2f + 1.0f - mod*(1.0f/5.0f); //generally fade in from nothing
  64.     alpha-=0.1f*(dist*mod*mod)*0.2f; //middle fades in first
  65.     Out.Color.a=alpha;
  66.     
  67.     //spit out the results
  68.     return Out;
  69. }
  70.